package utils;



import com.alibaba.fastjson.JSON;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author Lei
 * @create 2021-04-15 19:47
 */
public class ResultUtils {
    public static void toJson(HttpServletResponse response, Object data) throws IOException {
        String s = JSON.toJSONString(data);
        response.setContentType("text/json; charset=utf-8");
        response.setHeader("Cache-Control", "no-cache"); //取消浏览器缓存
        PrintWriter out = response.getWriter();
        out.print(s);
        out.flush();
        out.close();
    }

}
